package com.jlcindia.hibernate;

import org.hibernate.*;

import com.jlcindia.dao.CustomerDAO;
import com.jlcindia.dao.DAOFactory;
import com.jlcindia.util.CustomerTO;

public class ALab16 {
	public static void main(String args[]) {
		CustomerDAO cdao = DAOFactory.getCustomerDAO();
		
		//1.add customer
		CustomerTO cto = new CustomerTO(5, "ds", "ds@jlc.com", 9999, "Blore", "Enabled");
		cdao.addCustomer(cto);

		
		//2. get Customer
		CustomerTO c1 = cdao.getCustomerByCid(1);
		System.out.println(c1.getCid()+"\t"+c1.getCname()+"\t"+c1.getEmail()+"\t"+c1.getPhone()+"\t"+c1.getCity()+"\t"+c1.getStatus());
		
		// 3. delete Customer
		cdao.deleteCustomer(1);
		
		// 4.update Customer
		CustomerTO c2 = cdao.getCustomerByCid(2);
		c2.setCname("vas");
		c2.setEmail("vas@jlc");
		c2.setPhone(9999);
		cdao.updateCustomer(c2);
	}
}
